       IDENTIFICATION DIVISION.
      *--------------------------------------------------------------
       PROGRAM-ID. TP1.
      *--------------------------------------------------------------
       ENVIRONMENT DIVISION.
      *--------------------------------------------------------------
       CONFIGURATION SECTION.

       SPECIAL-NAMES.
           DECIMAL-POINT IS COMMA.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.
           SELECT VTAS-1 ASSIGN TO "C:\ARCHIVOS\ENTRADAS\VTAS1.TXT"
                                 ORGANIZATION IS LINE SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT VTAS-2 ASSIGN TO "C:\ARCHIVOS\ENTRADAS\VTAS2.TXT"
                                 ORGANIZATION IS LINE SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT VTAS-3 ASSIGN TO "C:\ARCHIVOS\ENTRADAS\VTAS3.TXT"
                                 ORGANIZATION IS LINE SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT VIAJES ASSIGN TO "C:\ARCHIVOS\ENTRADAS\VIAJES.TXT"
                                 ORGANIZATION IS LINE SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT MICROS ASSIGN TO "C:\ARCHIVOS\ENTRADAS\MICROS.TXT"
                                 ORGANIZATION IS LINE SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT TRAMOS ASSIGN TO "C:\ARCHIVOS\ENTRADAS\TRAMOS.TXT"
                                 ORGANIZATION IS LINE SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT RECHAZOS ASSIGN TO "C:\ARCHIVOS\SALIDAS\RECHAZOS.TXT"
                                 ORGANIZATION IS SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT LIST-TOT ASSIGN TO
                                 "C:\ARCHIVOS\SALIDAS\LISTTOTALES.TXT"
                                 ORGANIZATION IS SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.
           SELECT LIST-RECH ASSIGN TO
                                 "C:\ARCHIVOS\SALIDAS\LISTRECHAZOS.TXT"
                                 ORGANIZATION IS SEQUENTIAL
                                 ACCESS MODE IS SEQUENTIAL.

      *--------------------------------------------------------------
       DATA DIVISION.
      *-------------------------------------------------------------
       FILE SECTION.
       FD  VTAS-1       RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-VTAS-1.
           03 VTA1-CLAVE.
              05 VTA1-COD-MICRO               PIC 9(6).
              05 VTA1-COD-TRAMO               PIC 9(4).
              05 VTA1-FECHA                   PIC X(10).
              05 VTA1-HORA-PART               PIC X(5).
           03 VTA1-NRO-VENTA                  PIC 9(6).
           03 VTA1-IMPORTE                    PIC 9(4)V99.

       FD  VTAS-2       RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-VTAS-2.
           03 VTA2-CLAVE.
              05 VTA2-COD-MICRO               PIC 9(6).
              05 VTA2-COD-TRAMO               PIC 9(4).
              05 VTA2-FECHA                   PIC X(10).
              05 VTA2-HORA-PART               PIC X(5).
           03 VTA2-NRO-VENTA                  PIC 9(6).
           03 VTA2-IMPORTE                    PIC 9(4)V99.

       FD  VTAS-3       RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-VTAS-3.
           03 VTA3-CLAVE.
              05 VTA3-COD-MICRO               PIC 9(6).
              05 VTA3-COD-TRAMO               PIC 9(4).
              05 VTA3-FECHA                   PIC X(10).
              05 VTA3-HORA-PART               PIC X(5).
           03 VTA3-NRO-VENTA                  PIC 9(6).
           03 VTA3-IMPORTE                    PIC 9(4)V99.

       FD  VIAJES       RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-VIAJES.
           03 VIA-CLAVE.
              05 VIA-COD-MICRO                PIC 9(6).
              05 VIA-COD-TRAMO                PIC 9(4).
              05 VIA-FECHA                    PIC X(10).
              05 VIA-HORA-PART                PIC X(5).
           03 VIA-CANT-PASAJEROS              PIC 9(2).

       FD  MICROS       RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-MICROS.
           03 MIC-COD-MICRO                   PIC 9(6).
           03 MIC-DESC                        PIC X(30).

       FD  TRAMOS       RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-TRAMOS.
           03 TRA-COD-TRAMO                   PIC 9(4).
           03 TRA-DESC                        PIC X(30).

       FD  RECHAZOS     RECORDING MODE IS F
                        LABEL RECORD IS STANDARD.
       01  R-RECHAZOS.
           03 RECH-COD-MICRO                  PIC 9(6).
           03 RECH-COD-TRAMO                  PIC 9(4).
           03 RECH-FECHA                      PIC X(10).
           03 RECH-HORA-PART                  PIC X(5).
           03 RECH-NRO-VENTA                  PIC 9(6).
           03 RECH-IMPORTE                    PIC 9(4)V99.
           03 RECH-MOTIVO                     PIC X(20).
           03 RECH-AGENCIA                    PIC 9(1).

       FD  LIST-TOT     RECORDING MODE IS F
                        LABEL RECORD IS OMITTED.
       01  R-LIST-TOT                         PIC X(80).

       FD  LIST-RECH    RECORDING MODE IS F
                        LABEL RECORD IS OMITTED.
       01  R-LIST-RECH                        PIC X(80).


       WORKING-STORAGE SECTION.
      *****************************************************************
      *               DEFINICIONES     DE     TABLAS                  *
      *****************************************************************

       01  TABLA-MICROS.
           03  T-MIC OCCURS 300 TIMES.
               05  COD-MICRO                  PIC 9(6).
               05  DESC-MICRO                 PIC X(30).
       01  IND-MIC                            PIC 9(3).

       01  TABLA-TRAMOS.
           03  T-TRA OCCURS 100 TIMES.
               05  COD-TRAMO                  PIC 9(4).
               05  DESC-TRAMO                 PIC X(30).
       01  IND-TRA                            PIC 9(3).

       01  TABLA-ESTADISTICA.
           03  T-TRAMO OCCURS 100 TIMES.
               05  T-FRANJA-HR OCCURS 4 TIMES.
                   07  CN-VIAJ-INEXIST        PIC 9(3) VALUE 0.
                   07  CN-SOBREVTA            PIC 9(3) VALUE 0.
       01  I-TRAMO                            PIC 9(3).
       01  J-FRANJA                           PIC 9(1).

      *****************************************************************
      *               VARIABLES     DE     IMPRESION                  *
      *****************************************************************
      *                LISTADO      DE      PASAJES                   *
      *****************************************************************

       01  L-FECHA-HOJA.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(7) VALUE "FECHA: ".
           03  L-DIA                          PIC 9(2).
           03  FILLER                         PIC X(1) VALUE "/".
           03  L-MES                          PIC 9(2).
           03  FILLER                         PIC X(3) VALUE "/20".
           03  L-ANIO                         PIC 9(2).
           03  FILLER                         PIC X(36) VALUE SPACES.
           03  FILLER                         PIC X(5) VALUE "HOJA ".
           03  L-NRO-HOJA                     PIC ZZ9.

       01  L-DESCRIP.
           03  FILLER                         PIC X(20) VALUE SPACES.
           03  FILLER                         PIC X(37)
               VALUE "LISTADO DE PASAJES VENDIDOS APROBADOS".

       01  L-MICRO.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(14)
               VALUE "CODIGO MICRO: ".
           03  L-COD-MICRO                    PIC 9(6).
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(15)
               VALUE "DETALLE MICRO: ".
           03  L-DESC-MICRO                   PIC X(30).

       01  L-TRAMO.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(14)
               VALUE "CODIGO TRAMO: ".
           03  L-COD-TRAMO                    PIC 9(4).
           03  FILLER                         PIC X(3) VALUE SPACES.
           03  FILLER                         PIC X(15)
               VALUE "DETALLE TRAMO: ".
           03  L-DESC-TRAMO                   PIC X(30).

       01  L-FECHA-HR-PART.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(6) VALUE "FECHA:".
           03  FILLER                         PIC X(3) VALUE SPACES.
           03  L-FECHA                        PIC X(10).
           03  FILLER                         PIC X(2) VALUE SPACES.
           03  FILLER                         PIC X(6) VALUE "HORA: ".
           03  L-HORA-PART                    PIC X(5).

       01  L-ENC.
           03  FILLER                         PIC X(10) VALUE SPACES.
           03  FILLER                         PIC X(9)
               VALUE "NRO-VENTA".
           03  FILLER                         PIC X(5) VALUE SPACES.
           03  FILLER                         PIC X(7)
               VALUE "IMPORTE".
           03  FILLER                         PIC X(5) VALUE SPACES.
           03  FILLER                         PIC X(7)
               VALUE "AGENCIA".

       01  L-LINEA.
           03  FILLER                         PIC X(40)
               VALUE "----------------------------------------".
           03  FILLER                         PIC X(20)
               VALUE "--------------------".

       01  L-DETALLES.
           03  FILLER                         PIC X(10) VALUE SPACES.
           03  L-NRO-VTA                      PIC 9(6).
           03  FILLER                         PIC X(8) VALUE SPACES.
           03  L-IMPORTE                      PIC ZZZ9,99.
           03  FILLER                         PIC X(8) VALUE SPACES.
           03  L-AGENCIA                      PIC 9(1).

       01  L-TOT-VIAJ.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(17)
               VALUE "TOTALES POR VIAJE".
           03  FILLER                         PIC X(4) VALUE SPACES.
           03  FILLER                         PIC X(20)
               VALUE "CANTIDAD DE VENTAS  ".
           03  L-VTAS-VIAJ                    PIC ZZZ9.
           03  FILLER                         PIC X(4) VALUE SPACES.
           03  FILLER                         PIC X(9)
               VALUE "IMPORTE  ".
           03  L-IMP-VIAJ                     PIC ZZZZ9,99.

       01  L-TOT-GRAL.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  FILLER                         PIC X(17)
               VALUE "TOTALES GENERALES".
           03  FILLER                         PIC X(4) VALUE SPACES.
           03  FILLER                         PIC X(19)
               VALUE "CANTIDAD DE VENTAS ".
           03  L-VTAS-GRAL                    PIC ZZZZZ9.
           03  FILLER                         PIC X(3) VALUE SPACES.
           03  FILLER                         PIC X(8)
               VALUE "IMPORTE ".
           03  L-IMP-GRAL                     PIC ZZZZZZ9,99.

      *****************************************************************
      *               LISTADO      DE      ESTADISTICAS               *
      *****************************************************************

       01  L-ENC-ESTADIST.
           03  FILLER                         PIC X(30) VALUE SPACES.
           03  FILLER                         PIC X(23)
               VALUE "ESTADISTICA DE RECHAZOS".

       01  L-TITULO1-ESTAD.
           03  FILLER                         PIC X(18) VALUE SPACES.
           03  FILLER                         PIC X(44)
               VALUE "PASAJES INEXISTENTES / SOBREVENTA DE PASAJES".

       01  L-TITULO2-ESTAD.
           03  FILLER                         PIC X(12) VALUE SPACES.
           03  FILLER                         PIC X(13)
               VALUE "00:01-06:00Hs".
           03  FILLER                         PIC X(2) VALUE SPACES.
           03  FILLER                         PIC X(13)
               VALUE "06:01-12:00Hs".
           03  FILLER                         PIC X(2) VALUE SPACES.
           03  FILLER                         PIC X(13)
               VALUE "12:01-18:00Hs".
           03  FILLER                         PIC X(2) VALUE SPACES.
           03  FILLER                         PIC X(13)
               VALUE "18:01-00:00Hs".
           03  FILLER                         PIC X(2) VALUE SPACES.
           03  FILLER                         PIC X(6)
               VALUE "%TRAMO".

       01  L-DETALLES-ESTAD.
           03  FILLER                         PIC X(5)
               VALUE "TRAMO".
           03  L-NRO-TRAMO                    PIC ZZ9.
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  L-FRANJA1-INEXIST              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA1-SOB-VTA              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA2-INEXIST              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA2-SOB-VTA              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA3-INEXIST              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA3-SOB-VTA              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA4-INEXIST              PIC ZZ9,99.
           03  FILLER                         PIC X(2) VALUE "% ".
           03  L-FRANJA4-SOB-VTA              PIC ZZ9,99.
           03  FILLER                         PIC X(1) VALUE "%".
           03  FILLER                         PIC X(1) VALUE SPACES.
           03  L-PORC-TRAMO                   PIC ZZ9,99.
           03  FILLER                         PIC X(1) VALUE "%".

      *****************************************************************
      *                  VARIABLES      AUXILIARES                    *
      *****************************************************************

       01  WS-FECHA-ACTUAL.
           03  WS-ANIO                        PIC X(2).
           03  WS-MES                         PIC X(2).
           03  WS-DIA                         PIC X(2).

       01  WS-SEN-ENC                         PIC X(2).

       01  WS-CLAVE                           PIC X(25).

       01  WS-VTA-AUX.
           05  WS-COD-MICRO                   PIC 9(6).
           05  WS-COD-TRAMO                   PIC 9(4).
           05  WS-FECHA                       PIC X(10).
           05  WS-HORA-PART                   PIC X(5).
           03  WS-NRO-VENTA                   PIC 9(6).
           03  WS-IMPORTE                     PIC 9(4)V99.

       01  WS-AGENCIA                         PIC 9(1).

       01  WS-RECH-AUX.
           03  AUX-COD-MICRO                  PIC 9(6).
           03  AUX-COD-TRAMO                  PIC 9(4).
           03  AUX-FECHA                      PIC X(10).
           03  AUX-HORA-PART                  PIC X(5).
           03  AUX-NRO-VENTA                  PIC 9(6).
           03  AUX-IMPORTE                    PIC 9(4)V99.
           03  AUX-MOTIVO                     PIC X(20).
           03  AUX-AGENCIA                    PIC 9(1).

       01  WS-EOF.
           03  EOF-VTAS1                      PIC X(2) VALUE "NO".
               88  FIN-VTAS1                           VALUE "SI".
           03  EOF-VTAS2                      PIC X(2) VALUE "NO".
               88  FIN-VTAS2                           VALUE "SI".
           03  EOF-VTAS3                      PIC X(2) VALUE "NO".
               88  FIN-VTAS3                           VALUE "SI".
           03  EOF-VIAJES                     PIC X(2) VALUE "NO".
               88  FIN-VIAJES                          VALUE "SI".
           03  EOF-MICROS                     PIC X(2) VALUE "NO".
               88  FIN-MICROS                          VALUE "SI".
           03  EOF-TRAMOS                     PIC X(2) VALUE "NO".
               88  FIN-TRAMOS                          VALUE "SI".

       01  CN-CONTADORES.
           03  CN-LEIDOS-VTA1                 PIC 9(3) VALUE 0.
           03  CN-LEIDOS-VTA2                 PIC 9(3) VALUE 0.
           03  CN-LEIDOS-VTA3                 PIC 9(3) VALUE 0.
           03  CN-LEIDOS-VIAJ                 PIC 9(3) VALUE 0.
           03  CN-LEIDOS-MIC                  PIC 9(3) VALUE 0.
           03  CN-LEIDOS-TRA                  PIC 9(3) VALUE 0.
           03  CN-RECH-GRAB                   PIC 9(4) VALUE 0.
           03  CN-VTAS-VIA                    PIC 9(4) VALUE 0.
           03  CN-VTAS-GRAL                   PIC 9(6) VALUE 0.
           03  CN-LINEAS                      PIC 9(2) VALUE 0.
           03  CN-PAGINAS                     PIC 9(3) VALUE 1.
           03  CN-RECH-TRAMO                  PIC 9(3) VALUE 0.

       01  WS-PORCENTAJE-AUX                  PIC 9(3)V9999.

       01  AC-ACUMULADORES.
           03  AC-IMP-VIA                     PIC 9(5)V99 VALUE 0.
           03  AC-IMP-GRAL                    PIC 9(7)V99 VALUE 0.

      *---------------------------------------------------------------
       PROCEDURE DIVISION.
       MAIN.
           ACCEPT WS-FECHA-ACTUAL FROM DATE.
           MOVE WS-ANIO TO L-ANIO.
           MOVE WS-MES TO L-MES.
           MOVE WS-DIA TO L-DIA.
           PERFORM INICIO THRU F-INICIO.
           PERFORM LEO-VTAS1 THRU F-LEO-VTAS1.
           PERFORM LEO-VTAS2 THRU F-LEO-VTAS2.
           PERFORM LEO-VTAS3 THRU F-LEO-VTAS3.
           PERFORM LEO-VIAJES THRU F-LEO-VIAJES.
           PERFORM CARGO-MICROS THRU F-CARGO-MICROS UNTIL FIN-MICROS.
           PERFORM CARGO-TRAMOS THRU F-CARGO-TRAMOS UNTIL FIN-TRAMOS.
           PERFORM PROCESO THRU F-PROCESO UNTIL FIN-VTAS1 AND
                                                FIN-VTAS2 AND
                                                FIN-VTAS3 AND
                                                FIN-VIAJES.
           PERFORM IMP-TOTALES THRU F-IMP-TOTALES.
           PERFORM ENC-ESTADISTICAS THRU F-ENC-ESTADISTICAS.
           PERFORM IMP-ESTADISTICAS THRU F-IMP-ESTADISTICAS VARYING
                             I-TRAMO FROM 1 BY 1 UNTIL I-TRAMO > 100.
           PERFORM FIN THRU F-FIN.
           STOP RUN.

      *---------------------------------------------------------------
       INICIO.
              OPEN INPUT VTAS-1.
              OPEN INPUT VTAS-2.
              OPEN INPUT VTAS-3.
              OPEN INPUT TRAMOS.
              OPEN INPUT MICROS.
              OPEN INPUT VIAJES.
              OPEN OUTPUT RECHAZOS.
              OPEN OUTPUT LIST-TOT.
              OPEN OUTPUT LIST-RECH.
       F-INICIO. EXIT.

      *---------------------------------------------------------------
       FIN.
              CLOSE VTAS-1.
              CLOSE VTAS-2.
              CLOSE VTAS-3.
              CLOSE VIAJES.
              CLOSE TRAMOS.
              CLOSE MICROS.
              CLOSE RECHAZOS.
              CLOSE LIST-TOT.
              CLOSE LIST-RECH.
              DISPLAY "CANT.REG. LEIDOS EN VTAS1: " CN-LEIDOS-VTA1.
              DISPLAY "CANT.REG. LEIDOS EN VTAS2: " CN-LEIDOS-VTA2.
              DISPLAY "CANT.REG. LEIDOS EN VTAS3: " CN-LEIDOS-VTA3.
              DISPLAY "CANT.REG. LEIDOS EN VIAJES: " CN-LEIDOS-VIAJ.
              DISPLAY "CANT.REG. LEIDOS EN MICROS: " CN-LEIDOS-MIC.
              DISPLAY "CANT.REG. LEIDOS EN TRAMOS: " CN-LEIDOS-TRA.
              DISPLAY "CANT.RECHAZOS GRABADOS: " CN-RECH-GRAB.
       F-FIN. EXIT.

      *---------------------------------------------------------------
       LEO-VTAS1.
           READ VTAS-1
               AT END
                   SET FIN-VTAS1 TO TRUE
                   MOVE HIGH-VALUE TO VTA1-CLAVE
               NOT AT END
                   ADD 1 TO CN-LEIDOS-VTA1.
       F-LEO-VTAS1. EXIT.

      *---------------------------------------------------------------
       LEO-VTAS2.
           READ VTAS-2
               AT END
                   SET FIN-VTAS2 TO TRUE
                   MOVE HIGH-VALUE TO VTA2-CLAVE
               NOT AT END
                   ADD 1 TO CN-LEIDOS-VTA2.
       F-LEO-VTAS2. EXIT.

      *---------------------------------------------------------------
       LEO-VTAS3.
           READ VTAS-3
               AT END
                   SET FIN-VTAS3 TO TRUE
                   MOVE HIGH-VALUE TO VTA3-CLAVE
               NOT AT END
                   ADD 1 TO CN-LEIDOS-VTA3.
       F-LEO-VTAS3. EXIT.

      *---------------------------------------------------------------
       LEO-VIAJES.
           READ VIAJES
               AT END
                   SET FIN-VIAJES TO TRUE
                   MOVE HIGH-VALUE TO VIA-CLAVE
               NOT AT END
                   ADD 1 TO CN-LEIDOS-VIAJ.
       F-LEO-VIAJES. EXIT.

      *---------------------------------------------------------------
       LEO-MICROS.
           READ MICROS
               AT END
                   SET FIN-MICROS TO TRUE
               NOT AT END
                   ADD 1 TO CN-LEIDOS-MIC.
       F-LEO-MICROS. EXIT.

      *---------------------------------------------------------------
       LEO-TRAMOS.
           READ TRAMOS
               AT END
                   SET FIN-TRAMOS TO TRUE
               NOT AT END
                   ADD 1 TO CN-LEIDOS-TRA.
       F-LEO-TRAMOS. EXIT.

      *---------------------------------------------------------------
       CARGO-MICROS.
           PERFORM LEO-MICROS THRU F-LEO-MICROS.
      *     COMPUTE IND-MIC = MIC-COD-MICRO - 2000.
           MOVE MIC-COD-MICRO TO COD-MICRO(MIC-COD-MICRO - 2000).
           MOVE MIC-DESC TO DESC-MICRO(MIC-COD-MICRO - 2000).
       F-CARGO-MICROS. EXIT.

      *---------------------------------------------------------------
       CARGO-TRAMOS.
           PERFORM LEO-TRAMOS THRU F-LEO-TRAMOS.
           MOVE TRA-COD-TRAMO TO IND-TRA.
           MOVE TRA-COD-TRAMO TO COD-TRAMO(IND-TRA).
           MOVE TRA-DESC TO DESC-TRAMO(IND-TRA).
       F-CARGO-TRAMOS. EXIT.

      *---------------------------------------------------------------
       PROCESO.
           PERFORM DET-MENOR THRU F-DET-MENOR.
           PERFORM INICIALIZAR THRU F-INICIALIZAR.
           PERFORM PROC-VTAS1 THRU F-PROC-VTAS1 UNTIL
                                      FIN-VTAS1 OR
                                      WS-CLAVE NOT = VTA1-CLAVE.
           PERFORM PROC-VTAS3 THRU F-PROC-VTAS3 UNTIL
                                      FIN-VTAS3 OR
                                      WS-CLAVE NOT = VTA3-CLAVE.
           PERFORM PROC-VTAS2 THRU F-PROC-VTAS2 UNTIL
                                      FIN-VTAS2 OR
                                      WS-CLAVE NOT = VTA2-CLAVE.
           PERFORM PROC-VIAJES THRU F-PROC-VIAJES UNTIL
                                      FIN-VIAJES OR
                                      WS-CLAVE NOT = VIA-CLAVE.
           PERFORM ACUM-TOTALES THRU F-ACUM-TOTALES.
       F-PROCESO. EXIT.

      *---------------------------------------------------------------
       DET-MENOR.
           MOVE VTA1-CLAVE TO WS-CLAVE.
           IF VTA2-CLAVE < WS-CLAVE
              MOVE VTA2-CLAVE TO WS-CLAVE.
           IF VTA3-CLAVE < WS-CLAVE
              MOVE VTA3-CLAVE TO WS-CLAVE.
           IF VIA-CLAVE < WS-CLAVE
              MOVE VIA-CLAVE TO WS-CLAVE.
       F-DET-MENOR. EXIT.

      *---------------------------------------------------------------
       INICIALIZAR.
           MOVE 0 TO CN-VTAS-VIA.
           MOVE 0 TO AC-IMP-VIA.
           MOVE 0 TO CN-LINEAS.
           MOVE "NO" TO WS-SEN-ENC.
       F-INICIALIZAR. EXIT.

      *---------------------------------------------------------------
       PROC-VTAS1.
      ***************** VALIDO VENTA DE LA AGENCIA 1******************
      ******************* SI LA VENTA ES VALIDA **********************
           IF (WS-CLAVE = VIA-CLAVE) AND (VIA-CANT-PASAJEROS > 0)
               COMPUTE VIA-CANT-PASAJEROS = VIA-CANT-PASAJEROS - 1
               MOVE VTA1-COD-MICRO TO WS-COD-MICRO
               MOVE VTA1-COD-TRAMO TO WS-COD-TRAMO
               MOVE VTA1-FECHA TO WS-FECHA
               MOVE VTA1-HORA-PART TO WS-HORA-PART
               MOVE VTA1-NRO-VENTA TO WS-NRO-VENTA
               MOVE VTA1-IMPORTE TO WS-IMPORTE
               MOVE 1 TO WS-AGENCIA
               IF  WS-SEN-ENC = "NO"
                   PERFORM ENCABEZADO THRU F-ENCABEZADO
               END-IF
               PERFORM IMP-DETALLE THRU F-IMP-DETALLE
               PERFORM ACUM-VIAJE THRU F-ACUM-VIAJE
      ******************* LA VENTA NO ES VALIDA **********************
           ELSE
      *************** CARGO EL REG. AUX DEL RECHAZO ******************
               MOVE VTA1-COD-MICRO TO AUX-COD-MICRO
               MOVE VTA1-COD-TRAMO TO AUX-COD-TRAMO
               MOVE VTA1-FECHA TO AUX-FECHA
               MOVE VTA1-HORA-PART TO AUX-HORA-PART
               MOVE VTA1-NRO-VENTA TO AUX-NRO-VENTA
               MOVE VTA1-IMPORTE TO AUX-IMPORTE
               MOVE 1 TO AUX-AGENCIA
      *************** DETERMINO EL TIPO DEL RECHAZO ******************
               IF  WS-CLAVE NOT = VIA-CLAVE
                   PERFORM GRAB-RECH-INEXIST THRU F-GRAB-RECH-INEXIST
                   PERFORM REG-ESTADISTICA THRU F-REG-ESTADISTICA
               ELSE
                   PERFORM GRAB-RECH-SOB-VTA THRU F-GRAB-RECH-SOB-VTA
                   PERFORM REG-ESTADISTICA THRU F-REG-ESTADISTICA
               END-IF
           END-IF.
           PERFORM LEO-VTAS1 THRU F-LEO-VTAS1.
       F-PROC-VTAS1. EXIT.

      *---------------------------------------------------------------
       PROC-VTAS2.
      ***************** VALIDO VENTA DE LA AGENCIA 2******************
      ******************* SI LA VENTA ES VALIDA **********************
           IF (WS-CLAVE = VIA-CLAVE) AND (VIA-CANT-PASAJEROS > 0)
               COMPUTE VIA-CANT-PASAJEROS = VIA-CANT-PASAJEROS - 1
               MOVE VTA2-COD-MICRO TO WS-COD-MICRO
               MOVE VTA2-COD-TRAMO TO WS-COD-TRAMO
               MOVE VTA2-FECHA TO WS-FECHA
               MOVE VTA2-HORA-PART TO WS-HORA-PART
               MOVE VTA2-NRO-VENTA TO WS-NRO-VENTA
               MOVE VTA2-IMPORTE TO WS-IMPORTE
               MOVE 2 TO WS-AGENCIA
               IF  WS-SEN-ENC = "NO"
                   PERFORM ENCABEZADO THRU F-ENCABEZADO
               END-IF
               PERFORM IMP-DETALLE THRU F-IMP-DETALLE
               PERFORM ACUM-VIAJE THRU F-ACUM-VIAJE
      ******************* LA VENTA NO ES VALIDA **********************
           ELSE
      *************** CARGO EL REG. AUX DEL RECHAZO ******************
               MOVE VTA2-COD-MICRO TO AUX-COD-MICRO
               MOVE VTA2-COD-TRAMO TO AUX-COD-TRAMO
               MOVE VTA2-FECHA TO AUX-FECHA
               MOVE VTA2-HORA-PART TO AUX-HORA-PART
               MOVE VTA2-NRO-VENTA TO AUX-NRO-VENTA
               MOVE VTA2-IMPORTE TO AUX-IMPORTE
               MOVE 2 TO WS-AGENCIA
      *************** DETERMINO EL TIPO DEL RECHAZO ******************
               IF  WS-CLAVE NOT = VIA-CLAVE
                   PERFORM GRAB-RECH-INEXIST THRU F-GRAB-RECH-INEXIST
                   PERFORM REG-ESTADISTICA THRU F-REG-ESTADISTICA
               ELSE
                   PERFORM GRAB-RECH-SOB-VTA THRU F-GRAB-RECH-SOB-VTA
                   PERFORM REG-ESTADISTICA THRU F-REG-ESTADISTICA
               END-IF
           END-IF.
           PERFORM LEO-VTAS2 THRU F-LEO-VTAS2.
       F-PROC-VTAS2. EXIT.

      *---------------------------------------------------------------
       PROC-VTAS3.
      ***************** VALIDO VENTA DE LA AGENCIA 3******************
      ******************* SI LA VENTA ES VALIDA **********************
           IF (WS-CLAVE = VIA-CLAVE) AND (VIA-CANT-PASAJEROS > 0)
               COMPUTE VIA-CANT-PASAJEROS = VIA-CANT-PASAJEROS - 1
               MOVE VTA3-COD-MICRO TO WS-COD-MICRO
               MOVE VTA3-COD-TRAMO TO WS-COD-TRAMO
               MOVE VTA3-FECHA TO WS-FECHA
               MOVE VTA3-HORA-PART TO WS-HORA-PART
               MOVE VTA3-NRO-VENTA TO WS-NRO-VENTA
               MOVE VTA3-IMPORTE TO WS-IMPORTE
               MOVE 3 TO WS-AGENCIA
               IF  WS-SEN-ENC = "NO"
                   PERFORM ENCABEZADO THRU F-ENCABEZADO
               END-IF
               PERFORM IMP-DETALLE THRU F-IMP-DETALLE
               PERFORM ACUM-VIAJE THRU F-ACUM-VIAJE
      ******************* LA VENTA NO ES VALIDA **********************
           ELSE
      *************** CARGO EL REG. AUX DEL RECHAZO ******************
               MOVE VTA3-COD-MICRO TO AUX-COD-MICRO
               MOVE VTA3-COD-TRAMO TO AUX-COD-TRAMO
               MOVE VTA3-FECHA TO AUX-FECHA
               MOVE VTA3-HORA-PART TO AUX-HORA-PART
               MOVE VTA3-NRO-VENTA TO AUX-NRO-VENTA
               MOVE VTA3-IMPORTE TO AUX-IMPORTE
               MOVE 3 TO WS-AGENCIA
      *************** DETERMINO EL TIPO DEL RECHAZO ******************
               IF  WS-CLAVE NOT = VIA-CLAVE
                   PERFORM GRAB-RECH-INEXIST THRU F-GRAB-RECH-INEXIST
                   PERFORM REG-ESTADISTICA THRU F-REG-ESTADISTICA
               ELSE
                   PERFORM GRAB-RECH-SOB-VTA THRU F-GRAB-RECH-SOB-VTA
                   PERFORM REG-ESTADISTICA THRU F-REG-ESTADISTICA
               END-IF
           END-IF.
           PERFORM LEO-VTAS3 THRU F-LEO-VTAS3.
       F-PROC-VTAS3. EXIT.

      *---------------------------------------------------------------
       PROC-VIAJES.
           IF  WS-SEN-ENC = "SI"
               PERFORM IMP-TOT-VIA THRU F-IMP-TOT-VIA.
           PERFORM LEO-VIAJES THRU F-LEO-VIAJES.
       F-PROC-VIAJES. EXIT.

      *---------------------------------------------------------------
       ACUM-TOTALES.
           ADD CN-VTAS-VIA TO CN-VTAS-GRAL.
           ADD AC-IMP-VIA TO AC-IMP-GRAL.
       F-ACUM-TOTALES. EXIT.

      *---------------------------------------------------------------
       GRAB-RECH-INEXIST.
           MOVE "VIAJE INEXISTENTE" TO AUX-MOTIVO.
           WRITE R-RECHAZOS FROM WS-RECH-AUX.
           ADD 1 TO CN-RECH-GRAB.
       F-GRAB-RECH-INEXIST. EXIT.

      *---------------------------------------------------------------
       GRAB-RECH-SOB-VTA.
           MOVE "SOBREVENTA" TO AUX-MOTIVO.
           WRITE R-RECHAZOS FROM WS-RECH-AUX.
           ADD 1 TO CN-RECH-GRAB.
       F-GRAB-RECH-SOB-VTA. EXIT.

      *---------------------------------------------------------------
       ACUM-VIAJE.
           ADD 1 TO CN-VTAS-VIA.
           ADD WS-IMPORTE TO AC-IMP-VIA.
       F-ACUM-VIAJE. EXIT.

      *---------------------------------------------------------------
       REG-ESTADISTICA.
           MOVE AUX-COD-TRAMO TO I-TRAMO.
           IF  (AUX-HORA-PART > "00:00") AND (AUX-HORA-PART < "06:01")
               MOVE 1 TO J-FRANJA.
           IF  (AUX-HORA-PART > "06:01") AND (AUX-HORA-PART < "12:01")
               MOVE 2 TO J-FRANJA.
           IF  (AUX-HORA-PART > "12:01") AND (AUX-HORA-PART < "18:01")
               MOVE 3 TO J-FRANJA.
           IF  AUX-HORA-PART > "18:01"
               MOVE 4 TO J-FRANJA.
           IF  AUX-MOTIVO = "VIAJE INEXISTENTE   "
               ADD 1 TO CN-VIAJ-INEXIST(I-TRAMO, J-FRANJA)
           ELSE
               ADD 1 TO CN-SOBREVTA(I-TRAMO, J-FRANJA)
           END-IF.
       F-REG-ESTADISTICA. EXIT.

      *---------------------------------------------------------------
       ENCABEZADO.
           MOVE 0 TO CN-LINEAS.
           MOVE CN-PAGINAS TO L-NRO-HOJA.
           INITIALIZE R-LIST-TOT.
           WRITE R-LIST-TOT AFTER 2 LINES.
           WRITE R-LIST-TOT FROM L-FECHA-HOJA AFTER PAGE.
           ADD 1 TO CN-PAGINAS.
           ADD 2 TO CN-LINEAS.
           WRITE R-LIST-TOT FROM L-DESCRIP.
           ADD 1 TO CN-LINEAS.
      *     COMPUTE IND-MIC = WS-COD-MICRO - 2000.
           MOVE COD-MICRO(WS-COD-MICRO - 2000) TO L-COD-MICRO.
           MOVE DESC-MICRO(WS-COD-MICRO - 2000) TO L-DESC-MICRO.
           WRITE R-LIST-TOT FROM L-MICRO AFTER 2 LINES.
           ADD 2 TO CN-LINEAS.
           MOVE WS-COD-TRAMO TO IND-TRA.
           MOVE COD-TRAMO(IND-TRA) TO L-COD-TRAMO.
           MOVE DESC-TRAMO(IND-TRA) TO L-DESC-TRAMO.
           WRITE R-LIST-TOT FROM L-TRAMO.
           ADD 1 TO CN-LINEAS.
           MOVE WS-FECHA TO L-FECHA.
           MOVE WS-HORA-PART TO L-HORA-PART.
           WRITE R-LIST-TOT FROM L-FECHA-HR-PART.
           ADD 1 TO CN-LINEAS.
           WRITE R-LIST-TOT FROM L-ENC.
           ADD 1 TO CN-LINEAS.
           WRITE R-LIST-TOT FROM L-LINEA.
           ADD 1 TO CN-LINEAS.
      ****************************************************************
      *SE IMPRIMIO EL ENCABEZADO, POR LO TANTO SETEA SI A WS-SEN-ENC *
      ****************************************************************
           MOVE "SI" TO WS-SEN-ENC.
       F-ENCABEZADO. EXIT.

      *---------------------------------------------------------------
       IMP-DETALLE.
           IF  CN-LINEAS > 60
               PERFORM ENCABEZADO THRU F-ENCABEZADO.
           MOVE WS-NRO-VENTA TO L-NRO-VTA.
           MOVE WS-IMPORTE TO L-IMPORTE.
           MOVE WS-AGENCIA TO L-AGENCIA.
           WRITE R-LIST-TOT FROM L-DETALLES.
           ADD 1 TO CN-LINEAS.
       F-IMP-DETALLE. EXIT.

      *---------------------------------------------------------------
       IMP-TOT-VIA.
           IF  CN-LINEAS > 60
               PERFORM ENCABEZADO THRU F-ENCABEZADO.
           MOVE CN-VTAS-VIA TO L-VTAS-VIAJ.
           MOVE AC-IMP-VIA TO L-IMP-VIAJ.
           WRITE R-LIST-TOT FROM L-TOT-VIAJ AFTER 2 LINES.
           ADD 2 TO CN-LINEAS.
       F-IMP-TOT-VIA. EXIT.

      *---------------------------------------------------------------
       IMP-TOTALES.
           IF  CN-LINEAS > 60
               PERFORM ENCABEZADO THRU F-ENCABEZADO.
           MOVE CN-VTAS-GRAL TO L-VTAS-GRAL.
           MOVE AC-IMP-GRAL TO L-IMP-GRAL.
           WRITE R-LIST-TOT FROM L-TOT-GRAL AFTER 2 LINES.
           ADD 2 TO CN-LINEAS.
       F-IMP-TOTALES. EXIT.

      *---------------------------------------------------------------
       ENC-ESTADISTICAS.
           WRITE R-LIST-RECH FROM L-ENC-ESTADIST AFTER PAGE.
           WRITE R-LIST-RECH FROM L-TITULO1-ESTAD.
           WRITE R-LIST-RECH FROM L-TITULO2-ESTAD AFTER 2 LINES.
       F-ENC-ESTADISTICAS. EXIT.

      *---------------------------------------------------------------
       IMP-ESTADISTICAS.
           MOVE I-TRAMO TO L-NRO-TRAMO.
           COMPUTE CN-RECH-TRAMO = CN-VIAJ-INEXIST(I-TRAMO, 1) +
                                   CN-SOBREVTA(I-TRAMO, 1) +
                                   CN-VIAJ-INEXIST(I-TRAMO, 2) +
                                   CN-SOBREVTA(I-TRAMO, 2) +
                                   CN-VIAJ-INEXIST(I-TRAMO, 3) +
                                   CN-SOBREVTA(I-TRAMO, 3) +
                                   CN-VIAJ-INEXIST(I-TRAMO, 3) +
                                   CN-SOBREVTA(I-TRAMO, 4).
           IF CN-RECH-TRAMO > 0
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-VIAJ-INEXIST(I-TRAMO, 1) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA1-INEXIST
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-SOBREVTA(I-TRAMO, 1) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA1-SOB-VTA
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-VIAJ-INEXIST(I-TRAMO, 2) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA2-INEXIST
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-SOBREVTA(I-TRAMO, 2) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA2-SOB-VTA
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-VIAJ-INEXIST(I-TRAMO, 3) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA3-INEXIST
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-SOBREVTA(I-TRAMO, 3) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA3-SOB-VTA
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-VIAJ-INEXIST(I-TRAMO, 4) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA4-INEXIST
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-SOBREVTA(I-TRAMO, 4) / CN-RECH-TRAMO
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-FRANJA4-SOB-VTA
               COMPUTE WS-PORCENTAJE-AUX =
                   CN-RECH-TRAMO / CN-RECH-GRAB
               COMPUTE WS-PORCENTAJE-AUX = WS-PORCENTAJE-AUX * 100
               MOVE WS-PORCENTAJE-AUX TO L-PORC-TRAMO
               WRITE R-LIST-RECH FROM L-DETALLES-ESTAD AFTER 2 LINES
           END-IF.

       F-IMP-ESTADISTICAS. EXIT.

      *---------------------------------------------------------------